import { MailerService } from '@nestjs-modules/mailer';
import { Injectable } from '@nestjs/common';

@Injectable()
export class EmailService {

    constructor(readonly mailerService: MailerService){}

    async sendMail(email:string,vcode: string):Promise<any>{
        return this.mailerService.sendMail({
            to: email,
            from:"IM <1162280694@qq.com>",
            subject:"[IM]邮箱验证码",
            html:`<!DOCTYPE html>
            <html lang="en">
            <head>
                <meta charset="UTF-8">
                <meta http-equiv="X-UA-Compatible" content="IE=edge">
                <meta name="viewport" content="width=device-width, initial-scale=1.0">
                <title>Document</title>
                <style>
                    body{
                        text-align: center;
                    }
                    b{
                        color:rgb(122, 182, 32)
                    }
                </style>
            </head>
            <body>
                <p><h1>邮箱验证码</h1></p>
                <p>您的验证码为:<b>${vcode}</b></p>
                
            </body>
            </html>`
        })
    }
}
